// Load the net module to create a TCP server.
var net = require('net');

/*
 Create a new TCP server.
 The hanlder argument is automatically set as a listener for
 the 'connection' event.
*/
var server = net.createServer(function (socket) {

  // Every time someone connects, tell them hello and then close the connection.
  console.log("Connection from " + socket.remoteAddress);
  socket.end("Hello World\n");

});

var port = 8070;

// Fire up the server bound to port on localhost.
server.listen(port, "localhost");

// Put a friendly message on the terminal.
console.log("TCP server is listening on port " + port + " at localhost.");
